<!DOCTYPE html>
<HTML>
<HEAD><meta name="viewport" content="width=device-width, initial-scale=1">
<Title>Linear Zone Meter</Title>
<link type='text/css' rel='Stylesheet' href="maxchartapi.css" />
</HEAD>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">

<p class="heading0">ChartDirector 7.0 (Java Edition)</p>
<p class="heading1">Linear Zone Meter</p>
<hr class="separator">
<div class="content">
<img src="images/linearzonemeter.png" width='210' height='45'>
<br><br>
This example demonstrates a linear meter labelled with zones.<br><br>
The meter in this example is achieved by using <a href="LinearMeter.addZone.htm">LinearMeter.addZone</a> to add labelled zones. The black lines separating the zones are added by using <a href="BaseMeter.addLabel.htm">BaseMeter.addLabel</a> with empty spaces as labels.
</div>
<p class="heading1a">Source Code Listing</p>
<div class="content">
<b>[JSP Version]</b> jspdemo/linearzonemeter.jsp
<div class='codeblock'><code class='pre'>&lt;%@page import="ChartDirector.*, java.util.*" %&gt;
&lt;%
// The value to display on the meter
double value = 85;

// Create an LinearMeter object of size 210 x 45 pixels, using silver background with a 2 pixel
// black 3D depressed border.
LinearMeter m = new LinearMeter(210, 45, Chart.silverColor(), 0, -2);

// Set the scale region top-left corner at (5, 5), with size of 200 x 20 pixels. The scale labels
// are located on the bottom (implies horizontal meter)
m.setMeter(5, 5, 200, 20, Chart.Bottom);

// Set meter scale from 0 - 100
m.setScale(0, 100);

// Add a title at the bottom of the meter with a 1 pixel raised 3D border
m.addTitle2(Chart.Bottom, "Battery Level", "Arial Bold", 8).setBackground(Chart.Transparent, -1, 1);

// Set 3 zones of different colors to represent Good/Weak/Bad data ranges
m.addZone(50, 100, 0x99ff99, "Good");
m.addZone(20, 50, 0xffff66, "Weak");
m.addZone(0, 20, 0xffcccc, "Bad");

// Add empty labels (just need the ticks) at 0/20/50/80 as separators for zones
m.addLabel(0, " ");
m.addLabel(20, " ");
m.addLabel(50, " ");
m.addLabel(100, " ");

// Add a semi-transparent blue (800000ff) pointer at the specified value, using triangular pointer
// shape
m.addPointer(value, 0x800000ff).setShape(Chart.TriangularPointer);

// Output the chart
WebChartViewer viewer = new WebChartViewer(request, "chart1");
viewer.setChart(m, Chart.SVG);
%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Linear Zone Meter&lt;/title&gt;
    &lt;!-- Include ChartDirector Javascript Library to support chart interactions --&gt;
    &lt;script type="text/javascript" src="cdjcv.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body style="margin:5px 0px 0px 5px"&gt;
    &lt;div style="font:bold 18pt verdana;"&gt;
        Linear Zone Meter
    &lt;/div&gt;
    &lt;hr style="border:solid 1px #000080; background:#000080" /&gt;
    &lt;div style="font:10pt verdana; margin-bottom:1.5em"&gt;
        &lt;a href="viewsource.jsp?file=&lt;%=request.getServletPath()%&gt;"&gt;View Source Code&lt;/a&gt;
    &lt;/div&gt;
    &lt;!-- ****** Here is the chart image ****** --&gt;
    &lt;%= viewer.renderHTML(response) %&gt;
&lt;/body&gt;
&lt;/html&gt;</code></div>
</div>
<br><hr class="separator"><div class="copyright">&copy; 2022 Advanced Software Engineering Limited. All rights reserved.</div>
</body>
</HTML>
